home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / textual / pdftops / xpdf / h / XRef < prev   
Text File  |  1996-06-08  |  2KB  |  75 lines

  1. //========================================================================
  2. //
  3. // XRef.h
  4. //
  5. // Copyright 1996 Derek B. Noonburg
  6. //
  7. //========================================================================
  8.  
  9. #ifndef XREF_H
  10. #define XREF_H
  11.  
  12. #ifdef __GNUC__
  13. //#pragma interface
  14. #endif
  15.  
  16. #include <stdio.h>
  17. #include "gtypes.h"
  18.  
  19. class Object;
  20. class FileStream;
  21.  
  22. //------------------------------------------------------------------------
  23. // XRef
  24. //------------------------------------------------------------------------
  25.  
  26. struct XRefEntry {
  27.   int offset;
  28.   int gen;
  29.   GBool used;
  30. };
  31.  
  32. class XRef {
  33. public:
  34.  
  35.   // Constructor.  Read xref table from stream.
  36.   XRef(FileStream *str);
  37.  
  38.   // Destructor.
  39.   ~XRef();
  40.  
  41.   // Is xref table valid?
  42.   GBool isOk() { return ok; }
  43.  
  44.   // Is the PDF file encrypted?
  45.   GBool checkEncrypted();
  46.  
  47.   // Get catalog object.
  48.   Object *getCatalog(Object *obj) { return fetch(rootNum, rootGen, obj); }
  49.  
  50.   // Fetch an indirect reference.
  51.   Object *fetch(int num, int gen, Object *obj);
  52.  
  53. private:
  54.  
  55.   FILE *file;            // input file
  56.   int start;            // offset in file (to allow for garbage
  57.                 //   at beginning of file)
  58.   XRefEntry *entries;        // xref entries
  59.   int size;            // size of <entries> array
  60.   int rootNum, rootGen;        // catalog dict
  61.   GBool encrypted;        // true if file is encrypted
  62.   GBool ok;            // true if xref table is valid
  63.  
  64.   int readTrailer(FileStream *str);
  65.   GBool readXRef(FileStream *str, int *pos);
  66. };
  67.  
  68. //------------------------------------------------------------------------
  69. // The global xref table
  70. //------------------------------------------------------------------------
  71.  
  72. extern XRef *xref;
  73.  
  74. #endif
  75.